package main;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import controller.MessageController;
import controller.MySQL;
import javax.swing.JOptionPane;
import view.DialogException;
import view.FrameLogin;

/**
 *
 * @author Felipe
 */
public class Main {    
    
    public static void main(String[] args) {        
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }            
               
        MessageController.getInstance().addMessageListener(new MessageController.MessageListener() {
            @Override
            public void onReceiveMessage(String pMessage) {
                JOptionPane.showMessageDialog(null, pMessage);
            }

            @Override
            public void onReceiveExceptionMessage(String pMessage, Exception pException) {
                DialogException.getInstance().show(pMessage, pException);
            }
        });
        
        MySQL.getInstance().loadFromFile(); 
        
        FrameLogin.getInstance().setVisible(true);
    }
    
}